package com.googlecode.animator.data.cameras
{
	import com.googlecode.animator.data.IValueObject;
	import com.googlecode.animator.data.PositionObject3D;
	
	import org.papervision3d.core.math.Number3D;
	
	public class CameraVO extends PositionObject3D implements ICameraVO
	{
		
		public var gridOrientation:String;
		
		public var plane3DOrientation:String;		
		
		public var roll:int;
		
		public var target:Number3D = new Number3D(0,0,0);
			
		public var yUp:Boolean;
		
		public var zoom:int;
		
		public var zoomScale:int;
		
		override public function clone(src:* = null):IValueObject
		{
			if(src == null)
			{
				src = super.clone(new CameraVO());
			}else
			{
				src = super.clone(src);
			}
			
			src.gridOrientation = this.gridOrientation;
			src.plane3DOrientation = this.plane3DOrientation;
			src.roll = this.roll;
			src.target = this.target;			
			src.yUp = this.yUp;
			src.zoom = this.zoom;
			src.zoomScale = this.zoomScale;
			
			return src;
		}
		
		override public function toXML(src:XML = null):XML
		{	
			if(src == null)
			{
				src = super.toXML(<camera name={this.name} label={this.label}></camera>);
				
			}else
			{
				src = super.toXML(src);
			}	

			src.appendChild(<gridOrientation>{this.gridOrientation}</gridOrientation>);
			src.appendChild(<plane3DOrientation>{this.plane3DOrientation}</plane3DOrientation>);
			src.appendChild(<target></target>);		
			src.target.appendChild(<x>{this.target.x}</x>);
			src.target.appendChild(<y>{this.target.y}</y>);
			src.target.appendChild(<z>{this.target.z}</z>);			
			src.appendChild(<roll>{this.roll}</roll>);
			src.appendChild(<yUp>{this.yUp}</yUp>);
			src.appendChild(<zoom>{this.zoom}</zoom>);
			src.appendChild(<zoomScale>{this.zoomScale}</zoomScale>);
			
			return src;
		}
		
		override public function fromXML(src:XML):void
		{
			super.fromXML(src);

			this.gridOrientation = src.gridOrientation;
			this.plane3DOrientation = src.plane3DOrientation;
			this.target.x = src.target.x;
			this.target.y = src.target.y;
			this.target.z = src.target.z;			
			this.roll = src.roll;
			this.yUp = src.yUp;
			this.zoom = src.zoom;
			this.zoomScale = src.zoomScale;
		}
		
	}
}